<?php
/* @var $this CmpDepositController */
/* @var $model CmpDeposit */

$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'客户服务'=>array($this->pre_module_url.'/cmpServices/admin'),
	'退款管理'=>array($this->pre_module_url.'/refund/admin'),
	'提交退款'
);

?>

<div class="hr_15"></div>
<div class="steps">
	<ul class="fs_14 c_f">
		<li class="done done_a first"><span class="one">第一步,买家申请退款</span></li>
		<li class="cur"><span class="two">第二步，卖家处理退款申请</span></li>
		<li class="last"><span class="three">第三步，退款成功</span></li> 
	</ul>
</div>
<div class="hr_20"></div>

<div class="refund_box step_box">
	<!--未发货退款  start-->
	<div class="step_info">
		<div class="step_status">
			<div class="status">
				<p>
					<span class="ico_big ico_done"></span>
					<strong class="fs_14">
						<span>
							<?php if($model->zr_pay_status==1&&$model->zr_order_status==1){
								echo "卖家未发货，买家申请退款。等待卖家确认";
							}elseif($model->zr_pay_status==1&&$model->zr_order_status==2){
								echo "卖家已发货，买家未收到货,买家申请退款，等待买家确认";
							}elseif($model->zr_pay_status==1&&$model->zr_order_status==3){
								echo "买家已收到货,申请退款，等待买家确认是否需要退货，或直接退款";
							}elseif($model->zr_pay_status==3&&$model->zr_return==1){
								echo "卖家同意退款，等待买家退货";
							}elseif($model->zr_pay_status==3&&$model->zr_return==2){
								echo "买家已退货，等待卖家确认收货并退款";
							}
							?>
						</span>
					</strong>
				</p>
				<p class="c_999">
					<?php if($model->zr_pay_status==1){
						echo "如果卖家在<span id='countdown'>".(3600*7*24-(time()-$model->inputtime))."</span>之内没有处理退款订单，系统将自动处理买家申请！";
					}elseif($model->zr_pay_status==3&&$model->zr_return==1){
						echo "如果买家在 <span id='countdown'>".(3600*3*24-(time()-$model->zr_cmp_time))."</span>之内没有发货，本次退款申请无效！";
					}elseif($model->zr_pay_status==3&&$model->zr_return==2){
						echo "如果卖家在 <span id='countdown'>".(3600*15*24-(time()-$model->zr_user_time))."</span> 之内没有确认收货，系统将默认已收到货！系统将自动处理买家申请！";
					}
					?>
				</p>
			</div>
			<?php $form=$this->beginWidget('CActiveForm', array(
					'id'=>'refund-form-form',
					'enableAjaxValidation'=>false,
				)); ?>
				<ul class="form_list"> 
					<li class="c_f"><span class="tit f_l">退款凭证：</span>
						<div class="cert_img f_l">
							<p class="c_999">上传一张支付成功的截图以作凭证，图片大小不能大于500K。</p>
							<ul class="uploadimg c_f">
								<li class="f_l">
									<img id="img1" src="/images/cert_img.jpg" alt="" />
									<a class="mem_btn mem_btn10 filelink" href="javascript:" onclick="uploadimg('1')">点击上传
										<input type="file" id="uploadimg1" multiple name="image"/> 
									</a>
									<input type="hidden" id="proimage1" name="Refund[zr_cmp_pic][]" value="" />
								</li>
								<li class="f_l">
									<img id="img2" src="/images/cert_img.jpg" alt="" />
									<a class="mem_btn mem_btn10 filelink" href="javascript:" onclick="uploadimg('2')">点击上传
										<input type="file" id="uploadimg2" multiple name="image"/> 
									</a>
									<input type="hidden" id="proimage2" name="Refund[zr_cmp_pic][]" value="" />
								</li>
								<li class="f_l">
									<img id="img3" src="/images/cert_img.jpg" alt="" />
									<a class="mem_btn mem_btn10 filelink" href="javascript:" onclick="uploadimg('3')">点击上传
										<input type="file" id="uploadimg3" multiple name="image"/> 
									</a>
									<input type="hidden" id="proimage3" name="Refund[zr_cmp_pic][]" value="" />
								</li>
							</ul>
						</div>
					</li>
					<li class="link">
						<span class="tit"></span>
					</li>
				</ul>
			<?php $this->endWidget(); ?>
		</div>
		<ul class="form_list">
			<li><span class="tit">退款编号：</span><span><?php echo $model->zr_id?></span></li>
			<li><span class="tit">申请退款时间：</span><span><?php echo date('Y-m-d H:i',$model->inputtime)?></span></li>
			<li><span class="tit">退款类型：</span>
				<span>
					<?php if($model->zr_order_status==1){
						echo "卖家未发货";
					}elseif($model->zr_order_status==2){
						echo "卖家已发货，买家未收到货";
					}elseif($model->zr_order_status==3){
						echo "买家已收到货，需退货";
					}?>
				</span>
			</li>
			<li><span class="tit">退款状态：</span>
				<span>
					<?php if($model->zr_pay_status==1&&$model->zr_order_status==1){
						echo "卖家未发货，买家申请退款。等待卖家确认";
					}elseif($model->zr_pay_status==1&&$model->zr_order_status==2){
						echo "卖家已发货，买家未收到货,买家申请退款，等待买家确认";
					}elseif($model->zr_pay_status==1&&$model->zr_order_status==3){
						echo "买家已收到货,申请退款，等待买家确认是否需要退货，或直接退款";
					}elseif($model->zr_pay_status==3&&$model->zr_return==1){
						echo "卖家同意退款，等待买家退货";
					}elseif($model->zr_pay_status==3&&$model->zr_return==2){
						echo "买家已退货，等待卖家确认收货并退款";
					}elseif($model->zr_pay_status==4){
						echo "退款成功";
					}elseif($model->zr_pay_status==2){
						echo "退款失败";
					}
					?>
				</span>
			</li>
			<li><span class="tit">需要退款金额：</span><span><strong class="c_f60"><?php echo $model->zr_amount?></strong> 元</span></li>
			<li><span class="tit">退款原因：</span><span><?php echo CHtml::encode(Refund::model()->getReason($model->zr_reason))?></span></li> 
			<li class="c_f"><span class="tit f_l">退款凭证：</span>
				<div class="cert_img f_l">
					<ul class="c_f">
						<li><?php echo CHtml::image(!empty($model->zr_user_pic[0])?$model->zr_user_pic[0]:"/images/cert_img.jpg")?></li>
						<li><?php echo CHtml::image(!empty($model->zr_user_pic[1])?$model->zr_user_pic[1]:"/images/cert_img.jpg")?></li>
						<li><?php echo CHtml::image(!empty($model->zr_user_pic[2])?$model->zr_user_pic[2]:"/images/cert_img.jpg")?></li>
					</ul>
				</div>
			</li>
			<li><span class="tit">退款说明：</span><span><?php echo CHtml::encode($model->zr_content)?></span></li>
		</ul>       
	</div>
	<!--已发货退款  end -->
	<table class="list_table" cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<th width="35%">宝贝信息</th>
			<th width="15%">卖家</th>
			<th width="12%">单价（元）</th>
			<th width="12%">数量</th>
			<th width="14%">优惠</th>
			<th width="12%">小计（元）</th>
		</tr>
		<?php if(empty($model->zop_id)){?>
		<tr>
			<td class="pro tl">
				<div class="c_img c_img50">
					<?php echo CHtml::link(Tool::thumb($model->ordproduct->zop_pic,50,50),array('/home/product/detail','id'=>$model->ordproduct->zp_id),array('style'=>'display: inline; width: 50px; height: 50px;'))?>
				</div>
				<p class="title_pro">
					<?php echo CHtml::link(mb_substr($model->ordproduct->zop_title,0,20),array('/home/product/detail','id'=>$model->ordproduct->zp_id),array('class'=>'c_06c'))?>
				</p>
			</td>
			<td>
				<a class="c_06c" href="javascript:" title=""><?php echo $model->ordproduct->member->zm_name?></a>
			</td>
			<td><?php echo $model->ordproduct->zop_price?></td>
			<td><?php echo $model->ordproduct->zop_nums?></td>
			<td><span class="agio"><?php echo number_format(($model->ordproduct->zop_price*$model->ordproduct->zop_nums)/$model->ordproduct->zop_real_price*10,1,'.','')?>折优惠</span></td>
			<td><span class="fw_b fs_14 c_f60"><?php echo $model->ordproduct->zop_real_price?></span></td>
		</tr>
		<?php }else{ if(!empty($model->order)){ foreach($model->order->orderProduct as $val)?>
		<tr>
			<td class="pro tl">
				<div class="c_img c_img50">
					<?php echo CHtml::link(Tool::thumb($val->zop_pic,50,50),array('/home/product/detail','id'=>$val->zp_id),array('style'=>'display: inline; width: 50px; height: 50px;'))?>
				</div>
				<p class="title_pro">
					<?php echo CHtml::link(mb_substr($val->zop_title,0,20),array('/home/product/detail','id'=>$val->zp_id),array('class'=>'c_06c'))?>
				</p>
			</td>
			<td>
				<a class="c_06c" href="javascript:" title=""><?php echo $val->member->zm_name?></a>
			</td>
			<td><?php echo $val->zop_price?></td>
			<td><?php echo $val->zop_nums?></td>
			<td><span class="agio"><?php echo number_format(($val->zop_price*$val->zop_nums)*10/$val->zop_real_price,1,'.','')?>折优惠</span></td>
			<td><span class="fw_b fs_14 c_f60"><?php echo $val->zop_real_price?></span></td>
		</tr>
		<?php }} ?>
	</table>
</div>
<!--退款管理 end-->
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.ui.widget.js"></script>  
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.iframe-transport.js"></script>  
<script src="<?php echo Yii::app()->baseUrl;?>/js/jquery.fileupload.js"></script>  
<script type="text/javascript">
//倒计时
jQuery(function(){
		countdown("countdown")
	});
//上传产品图片
function uploadimg (id) {
	   $('#uploadimg'+id).fileupload({         	
	        dataType: 'json',       
	        url: '/Attachment/GetAjax',        
	        success: function (json) {
	               if(json.upfile.errors=='1'){
	               		alert(json.upfile.msg);
	               }else if(json.upfile.errors=='2'){
	               		alert(json.upfile.msg);
	               }else{
		                 //修改按钮图标
		            	 $('#img'+id).attr('src',json.upfile.file);
						 //修改按钮文本
		            	 $('#img'+id).parent().find('a').eq(0).html('修改图片<input type="file" id="uploadimg'+id+'" multiple name="image"/>');
		            	 //填加删除按钮
		            	 if(!$('#img'+id).parent().find('a')[1]){
		            		 $('#img'+id).parent().find('a').after('<a class="mem_btn mem_btn10" href="javascript:" onclick="removeimg(\''+id+'\')">删除图片</a>');
		            	 }
						 //修改隐藏域值
	               		 $('#proimage'+id).attr('value',json.upfile.file);
	               } 	
	        }
	    });
};
//删除产品图片
function removeimg(id){
	$('#img'+id).parent().find('a').eq(0).html('上传图片<input type="file" id="uploadimg'+id+'" multiple name="image"/>');
	$('#img'+id).parent().find('a').eq(1).remove();
	$('#img'+id).attr('src','/images/pro_img.jpg');
	$('#proimage'+id).attr('value','');
}
</script>

